package com.itheima.dao;

import com.itheima.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    @Select("select id,book_name AS bookName,author,price,file from book where id=#{id}")
    Book findBookById(Integer id);

    @Insert("insert into book values(null,#{bookName},#{author},#{price},#{file})")
    boolean addBook(Book book);

    @Select("select id,book_name AS bookName,author,price from book")
    List<Book> findAllBook();

    @Update("update book set book_name=#{bookName},author=#{author},price=#{price} where id=#{id}")
    boolean updateBook(Book book);

    @Delete("delete from book where id=#{id}")
    boolean deleteBook(Integer id);

    List<Book> searchBook(@Param("bookName") String bookName,  @Param("author") String author,
                          @Param("minPrice") String minPrice,  @Param("maxPrice") String maxPrice);
}

